<template>
	<view class="content">
		<bgyx-nav-bar name="广场">
			<view style="display: flex;align-items: center;margin-bottom: 8rpx;">
				<image @click="gofabu" src="/static/images/addmn.png"
					style="width: 50rpx;height: 50rpx;margin-right: 15rpx;" mode=""></image>
			</view>
		</bgyx-nav-bar>

		<scroll-view @scrolltolower="scrolltolower" class="indexcontent" style="padding: 0rpx;" :scroll-y="true">
			<view style="width: 720rpx;display: flex;align-items: flex-start;margin-bottom: 15rpx;padding: 15rpx;"
				v-for="(item,k) in list">
				<view style="display: flex;width: 100%;">
					<view style="margin-right: 15rpx;">
						<u-avatar @click="gofriend(item.uid)"
							:src="$store.state.common.systemInfo.fileurl + 'avatar/' + item.uid + '.jpg'"
							mode="square"></u-avatar>
					</view>
					<view style="display: flex;flex-direction: column;flex: 1;">
						<view class="">
							{{item.title}}
						</view>
						<view style="margin-top: 10rpx;width: 100%;">
							<bgyx-pyq-images :images="item.images" />
						</view>
						<view style="margin-top: 10rpx;font-size: 22rpx;color: #b8b8b8;width: 100%;">
							{{$u.timeFormat(item.time, 'yyyy-mm-dd hh:MM:ss')}}
						</view>
					</view>
				</view>
			</view>
		</scroll-view>



		<bgyx-tab-bar />
	</view>


</template>

<script>
	import {
		mapState
	} from 'vuex';
	import {
		pub
	} from '../../common/event';
	export default {
		data() {
			return {

			}
		},
		components: {

		},
		computed: {
			...mapState({
				list: (state) => {
					return state.pyq.list.sort((a, b) => b.time - a.time).map(e => {
						const images = JSON.parse(e.images)
						return {
							...e,
							images
						}
					})
				}
			})
		},

		onLoad() {
			this.getdata()
		},
		methods: {
			scrolltolower: async function() {
				if (this.list.length > 0 && this.list.length >= 50) {
					const t = this.list[this.list.length - 1]
					const time = t.time
					this.$store.dispatch({
						type: "pyq/getmorepyqinfo",
						payload: {
							time
						}
					})
				}
			},
			getdata: async function() {

			},
			gofriend: async function(uid) {
				const list = this.$store.state.friend.list
				const user = this.$store.state.user.user
				if (user.id == uid) {
					return
				}
				const ret = list.find(e => {
					return e.fid == uid
				})
				if (ret) {
					uni.navigateTo({
						url: "/pages/friend/detail?id=" + uid
					})
				} else {
					uni.navigateTo({
						url: "/pages/friend/friend?id=" + uid
					})
				}
			},
			gologin: async function() {
				uni.switchTab({
					url: "/pages/friend/index"
				})
			},
			gofabu: async function() {
				uni.navigateTo({
					url: "/pages/news/fabu"
				})
			},
		}
	}
</script>


<style scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 100%;
		height: 100vh;
		overflow-y: hidden;
		padding-bottom: 120rpx;
		border-start-end-radius: 32rpx;
		border-start-start-radius: 32rpx;
	}
</style>